package com.haima.ziliao.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.haima.ziliao.domain.PChanpin;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.haima.common.annotation.Log;
import com.haima.common.core.controller.BaseController;
import com.haima.common.core.domain.AjaxResult;
import com.haima.common.enums.BusinessType;
import com.haima.ziliao.domain.PYanxuetuijian;
import com.haima.ziliao.service.IPYanxuetuijianService;
import com.haima.common.utils.poi.ExcelUtil;
import com.haima.common.core.page.TableDataInfo;

/**
 * 研学推荐Controller
 * 
 * @author hima
 * @date 2024-12-22
 */
@RestController
@RequestMapping("/ziliao/yanxuetuijian")
public class PYanxuetuijianController extends BaseController
{
    @Autowired
    private IPYanxuetuijianService pYanxuetuijianService;

    /**
     * 查询研学推荐列表
     */
    @PreAuthorize("@ss.hasPermi('ziliao:yanxuetuijian:list')")
    @GetMapping("/list")
    public TableDataInfo list(PYanxuetuijian pYanxuetuijian)
    {
        startPage();
        List<PYanxuetuijian> list = pYanxuetuijianService.selectPYanxuetuijianList(pYanxuetuijian);
        return getDataTable(list);
    }

    @GetMapping("/getTuijian")
    public AjaxResult getTuijian(PYanxuetuijian pYanxuetuijian)
    {
        List<PYanxuetuijian> list = pYanxuetuijianService.selectPYanxuetuijianList(pYanxuetuijian);
        return AjaxResult.success(list);
    }

    /**
     * 导出研学推荐列表
     */
    @PreAuthorize("@ss.hasPermi('ziliao:yanxuetuijian:export')")
    @Log(title = "研学推荐", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PYanxuetuijian pYanxuetuijian)
    {
        List<PYanxuetuijian> list = pYanxuetuijianService.selectPYanxuetuijianList(pYanxuetuijian);
        ExcelUtil<PYanxuetuijian> util = new ExcelUtil<PYanxuetuijian>(PYanxuetuijian.class);
        util.exportExcel(response, list, "研学推荐数据");
    }

    /**
     * 获取研学推荐详细信息
     */
    @PreAuthorize("@ss.hasPermi('ziliao:yanxuetuijian:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pYanxuetuijianService.selectPYanxuetuijianById(id));
    }

    /**
     * 新增研学推荐
     */
    @PreAuthorize("@ss.hasPermi('ziliao:yanxuetuijian:add')")
    @Log(title = "研学推荐", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PYanxuetuijian pYanxuetuijian)
    {
        return toAjax(pYanxuetuijianService.insertPYanxuetuijian(pYanxuetuijian));
    }

    /**
     * 修改研学推荐
     */
    @PreAuthorize("@ss.hasPermi('ziliao:yanxuetuijian:edit')")
    @Log(title = "研学推荐", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PYanxuetuijian pYanxuetuijian)
    {
        return toAjax(pYanxuetuijianService.updatePYanxuetuijian(pYanxuetuijian));
    }

    /**
     * 删除研学推荐
     */
    @PreAuthorize("@ss.hasPermi('ziliao:yanxuetuijian:remove')")
    @Log(title = "研学推荐", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pYanxuetuijianService.deletePYanxuetuijianByIds(ids));
    }
}
